<template>
  <div class="status-test">
    <h3>状态样式测试</h3>
    <div class="test-grid">
      <div v-for="status in testStatuses" :key="status.name" class="test-item">
        <span>{{ status.name }}:</span>
        <span :class="['status-text', getStatusClass(status.value)]">
          {{ status.value }}
        </span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const testStatuses = [
  { name: 'Accepted', value: 'Accepted' },
  { name: 'Wrong Answer', value: 'Wrong Answer' },
  { name: 'Compile Error', value: 'Compile Error' },
  { name: 'Memory Limit', value: 'Memory Limit Exceeded' },
  { name: 'Time Limit', value: 'Time Limit Exceeded' },
  { name: 'Waiting', value: 'Waiting' },
  { name: 'Runtime Error', value: 'Runtime Error' },
  { name: 'System Error', value: 'System Error' },
]

// 获取状态样式类
const getStatusClass = (status: string) => {
  console.log('getStatusClass called with:', status)
  switch (status) {
    case 'Accepted':
    case '成功':
      return 'status-success'
    
    case 'Wrong Answer':
    case '答案错误':
      return 'status-wrong'
    
    case 'Compile Error':
    case '编译错误':
      return 'status-compile-error'
    
    case 'Memory Limit Exceeded':
    case '内存溢出':
      return 'status-memory-limit'
    
    case 'Time Limit Exceeded':
    case '超时':
      return 'status-time-limit'
    
    case 'Presentation Error':
    case '展示错误':
      return 'status-presentation-error'
    
    case 'Waiting':
    case '等待中':
      return 'status-waiting'
    
    case 'Output Limit Exceeded':
    case '输出溢出':
      return 'status-output-limit'
    
    case 'Dangerous Operation':
    case '危险操作':
      return 'status-dangerous'
    
    case 'Runtime Error':
    case '运行错误':
      return 'status-runtime-error'
    
    case 'System Error':
    case '系统错误':
      return 'status-system-error'
    
    default:
      return 'status-default'
  }
}
</script>

<style>
/* 状态样式 - 全局样式 */
.status-text {
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  min-width: 80px;
  text-align: center;
}

/* 成功状态 - 绿色 */
.status-success {
  color: #ffffff !important;
  background-color: #52c41a !important;
  border: 1px solid #52c41a !important;
}

/* 答案错误 - 红色 */
.status-wrong {
  color: #ffffff !important;
  background-color: #ff4d4f !important;
  border: 1px solid #ff4d4f !important;
}

/* 编译错误 - 深红色 */
.status-compile-error {
  color: #ffffff !important;
  background-color: #cf1322 !important;
  border: 1px solid #cf1322 !important;
}

/* 内存溢出 - 橙红色 */
.status-memory-limit {
  color: #ffffff !important;
  background-color: #fa541c !important;
  border: 1px solid #fa541c !important;
}

/* 超时 - 橙色 */
.status-time-limit {
  color: #ffffff !important;
  background-color: #fa8c16 !important;
  border: 1px solid #fa8c16 !important;
}

/* 展示错误 - 黄色 */
.status-presentation-error {
  color: #333333 !important;
  background-color: #fadb14 !important;
  border: 1px solid #fadb14 !important;
}

/* 等待中 - 蓝色 */
.status-waiting {
  color: #ffffff !important;
  background-color: #1890ff !important;
  border: 1px solid #1890ff !important;
  animation: pulse 2s infinite;
}

/* 输出溢出 - 紫色 */
.status-output-limit {
  color: #ffffff !important;
  background-color: #722ed1 !important;
  border: 1px solid #722ed1 !important;
}

/* 危险操作 - 深红色 */
.status-dangerous {
  color: #ffffff !important;
  background-color: #a8071a !important;
  border: 1px solid #a8071a !important;
}

/* 运行错误 - 品红色 */
.status-runtime-error {
  color: #ffffff !important;
  background-color: #eb2f96 !important;
  border: 1px solid #eb2f96 !important;
}

/* 系统错误 - 灰色 */
.status-system-error {
  color: #ffffff !important;
  background-color: #595959 !important;
  border: 1px solid #595959 !important;
}

/* 默认状态 - 浅灰色 */
.status-default {
  color: #333333 !important;
  background-color: #f5f5f5 !important;
  border: 1px solid #d9d9d9 !important;
}

/* 等待中状态的脉冲动画 */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
  }
}
</style>

<style scoped>
.status-test {
  padding: 20px;
  background: white;
  border-radius: 8px;
  margin: 20px;
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.test-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
}
</style>
